package com.demo.jfinalDemo.web;

import java.util.Arrays;

import com.jfinal.core.ActionKey;
import com.jfinal.core.Controller;

public class HelloController extends Controller {
	public void index() {
		renderText("Hello JFinal World.");
	}
	
	@ActionKey("sayHi")	//打破route规则，不加@ActionKey之前访问路径是/hello/sayHi，加了之后是/sayHi
	public void sayHi() {
		renderText("sayHi");
	}
	
	//url:/hello/param/zhangsan-20?address=addr
	public void param() {
		String urlPara = getPara();
		String name = getPara(0);
		int age = getParaToInt(1);
		String address = getPara("address");
		
		renderText(String.format("urlPara=%s,name=%s,age=%d,address=%s", urlPara, name, age, address));
	}
	
	public void list() {
		renderJson(Arrays.asList("admin","zhang","li","wang"));
	}
	
	public void view() {
		renderJsp("view.jsp");
	}
	
	
}
